package net.wwang.blog.config;

import net.wwang.blog.commons.global.Constants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;


/**
 * 异步串口配置
 *
 * @author WangWei
 * @date 2020/8/14
 */
@Configuration
@EnableAsync
public class AsyncConfig {
	@Bean
	public Executor asyncExcuter() {
		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
		executor.setCorePoolSize(2);
		executor.setMaxPoolSize(10);
		executor.setThreadNamePrefix(Constants.User.BLOG_TASK_WORKER);
		executor.setQueueCapacity(30);
		executor.initialize();
		return executor;
	}
}
